package com.weipai.education.dao.impl;

import com.weipai.education.dao.UserAddressDao;
import com.weipai.education.mapper.UserAddressMapper;
import com.weipai.education.model.UserAddress;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: 曹朋飞
 * @Date: 2018/12/18 09:38
 */
@Repository
public class UserAddressDaoImpl implements UserAddressDao {

    @Autowired
    private UserAddressMapper userAddressMapper;

    @Override
    public List<UserAddress> getUserAddress(String userId) {
        return userAddressMapper.getUserAddress(userId);
    }

    @Override
    public UserAddress getUserIsDefaultAddress(String userId, int isDefault) {
        return userAddressMapper.getUserIsDefaultAddress(userId, isDefault);
    }

    @Override
    public int update(UserAddress userAddress1) {
        return userAddressMapper.updateByPrimaryKeySelective(userAddress1);
    }

    @Override
    public int insert(UserAddress userAddress) {
        return userAddressMapper.insert(userAddress);
    }

    @Override
    public int deleteUserAddress(String id) {
        return userAddressMapper.deleteByPrimaryKey(Integer.parseInt(id));
    }
}
